#!/usr/bin/ruby -Ku
# -*- coding: utf-8 -*-
require 'test/unit'
require 'm3g'

class Test_PolygonMode < Test::Unit::TestCase
  def setup
  end

  def teadown
  end

  def test_defualt_variables
    pmode = M3G::PolygonMode.new

    # 注意: このデフォルト値はM3Gの仕様とは異なる。
    # デスクトップ用に見た目重視に変更した。

    assert_equal M3G::PolygonMode::CULL_BACK   , pmode.culling
    assert_equal M3G::PolygonMode::WINDING_CCW , pmode.winding
    assert_equal M3G::PolygonMode::SHADE_SMOOTH, pmode.shading
    assert_equal false, pmode.two_sided_lighting_enabled?
    assert_equal true , pmode.local_camera_lighting_enabled?
    assert_equal true , pmode.perspective_correction_enabled?
  end

  def test_set_variables
    pmode = M3G::PolygonMode.new
  
    pmode.culling = M3G::PolygonMode::CULL_NONE
    pmode.winding = M3G::PolygonMode::WINDING_CW
    pmode.shading = M3G::PolygonMode::SHADE_FLAT
    pmode.two_sided_lighting_enable     = true
    pmode.local_camera_lighting_enable  = false
    pmode.perspective_correction_enable = false

    assert_equal M3G::PolygonMode::CULL_NONE , pmode.culling
    assert_equal M3G::PolygonMode::WINDING_CW, pmode.winding
    assert_equal M3G::PolygonMode::SHADE_FLAT, pmode.shading
    assert_equal true , pmode.two_sided_lighting_enabled?
    assert_equal false, pmode.local_camera_lighting_enabled?
    assert_equal false, pmode.perspective_correction_enabled?

  end

  def test_duplicate
    pmode1 = M3G::PolygonMode.new
  
    pmode1.culling = M3G::PolygonMode::CULL_NONE
    pmode1.winding = M3G::PolygonMode::WINDING_CW
    pmode1.shading = M3G::PolygonMode::SHADE_FLAT
    pmode1.two_sided_lighting_enable     = true
    pmode1.local_camera_lighting_enable  = false
    pmode1.perspective_correction_enable = false

    pmode2 = pmode1.duplicate

    assert_not_equal pmode1, pmode2
    assert_equal M3G::PolygonMode::CULL_NONE , pmode2.culling
    assert_equal M3G::PolygonMode::WINDING_CW, pmode2.winding
    assert_equal M3G::PolygonMode::SHADE_FLAT, pmode2.shading
    assert_equal true , pmode2.two_sided_lighting_enabled?
    assert_equal false, pmode2.local_camera_lighting_enabled?
    assert_equal false, pmode2.perspective_correction_enabled?
  end
end

